<template>
    <div class="patientLeftSidebar-view leftSidebar">

      <sidebar-item
        v-for="(data, index) in datas"
        :data="data"
        :index="index"
        :active-inx="selectIndex"
        @item-click="itemClick(index)"
      ></sidebar-item>

    </div>
</template>

<script>
  import sidebarItem from "../../../components/sidebarItem";
    export default {
        name: "patientLeftSidebar",
        components:{sidebarItem},
        data:function () {
            return{
                datas:[
                    {
                        title: "今天",
                        iconType: "iconFont",
                        iconFont: "iconfont icon-day",
                    },
                    {
                        title: "昨天",
                        iconType: "iconFont",
                        iconFont: "iconfont icon-zuo",
                    },
                    {
                        title: "近一周",
                        iconType: "iconFont",
                        iconFont: "iconfont icon-zhou",
                    },
                    {
                        title: "近一个月",
                        iconType: "iconFont",
                        iconFont: "iconfont icon-yue",
                    },
                    {
                        title: "近一年",
                        iconType: "iconFont",
                        iconFont: "iconfont icon-nian",
                    },
                    {
                        title: "全部",
                        iconType: "iconFont",
                        iconFont: "iconfont icon-fujiafeiyong3x",
                    },
                ],
                selectIndex:0,
            }
        },
        mounted:function(){
          if (this.$route.query.type){
              this.selectIndex = Number(this.$route.query.type);
          }else {
              this.selectIndex = 0;
          }
        },
        methods:{
            itemClick: function (index) {
                if (index == this.selectIndex && this.$route.path.indexOf("patientDetails") == -1) {
                    this.$emit("update-view");
                } else {
                    this.$router.push({name:"patientList",query:{type:index,t:new Date().getTime()}})
                }
            },
        }
    }
</script>

<style lang="scss" scoped>
  @import "@/assets/scss/components/leftSidebar.scss";
</style>
